<template>
  <div>
    <div class="table_box" v-loading="loading">
      <el-table :data="tableData" ref="multipleTable" class="historyTable" style="width: 100%">
        <el-table-column prop="name" label="用户名" show-overflow-tooltip>
          <template #default="scope">

            <div class="peopleBox">
              <div class="people">
                <span>{{ scope.row.nickName ? scope.row.nickName.slice(-2) : "" }}</span>
              </div>
              {{ scope.row.nickName }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="editionName" label="文件版本">
          <template #default="scope">
            {{ scope.row.filesEdition == fileDetailInfo.editionName ? "当前" : scope.row.filesEditionName }}
          </template>
        </el-table-column>
        <el-table-column prop="viewedTime" label="查看时间"></el-table-column>
      </el-table>
    </div>
    <div class="block">
      <el-pagination @current-change="handleCurrentChange" :current-page.sync="requestStr.page"
        :page-size="requestStr.size" layout="total, prev, pager, next" :total="requestStr.total">
      </el-pagination>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { apiFilesRecentlyViewedCheck } from "@/api/teamKnowdge/teamDocApi"
const loading = ref(false)
const tableData = ref([])
const requestStr = reactive({
  page: 1,
  size: 10,
  total: 0,
})
const parentOdj = ref({})

const props = defineProps({
  fileDetailInfo: {
    type: Object,
    default: () => {
      return {}
    },
  }
})


const getList = async (row) => {
  loading.value = true
  parentOdj.value = row
  const res = await apiFilesRecentlyViewedCheck({
    filesId: row.id,
    libraryType: 'team',
    page: requestStr.page - 1,
    size: requestStr.size,
  })
  if (res.code == 200) {
    loading.value = false
    tableData.value = res.data.rows
    requestStr.total = res.data.total
  } else {
    loading.value = false
  }
}
const handleCurrentChange = (val) => {
  requestStr.page = val
  getList(parentOdj.value)
}
defineExpose({
  getList
})
</script>


<style scoped lang="scss">
.table_box {
  :deep(th) {
    color: #666;
    font-weight: normal;
    font-size: 14px;
    height: 51px;
  }

  :deep(tr) {
    color: #333;
    height: 51px;
  }

  :deep(.el-table__body tr:hover .realName_box_right) {
    visibility: visible;
  }
}

.peopleBox {
  display: flex;
  align-items: center;

  .people {
    width: 26px;
    height: 26px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    background-color: #56abfb;
    margin-right: 3px;

    span {
      display: inline-block;
      margin-top: 2px;
      transform: scale(0.9, 0.9);
    }
  }
}
</style>
